package xyz.fefine;

import java.io.IOException;

/**
 * Created by feng_ on 2016/8/31.
 * 词法分析异常
 */
public class ParseException extends Exception {
    public ParseException(Token T){
        this("",T);
    }
    public ParseException(String msg,Token t) {
        super("synatx error around "+location(t)+"."+msg);
    }
    private static String location(Token t) {
        if (t == Token.EOF) {
            return "the last line";
        }else{
            return "\""+t.getString()+" at line "+t.getLineNumber();
        }
    }
    public ParseException(IOException o)
    {
        super(o);
    }
    public ParseException(String msg){
        super(msg);
    }
}
